<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>JavaScript 数组排序 </title>
</head>
<body>
<h2>数字排序</h2>
<p>通过一个比值函数来修正字符串排序时25>100问题</p>

<p>单击按钮以升序对数组进行排序。</p>

<button onclick="myFunction()">试一试</button>

<p id="demo"></p>

<script>
  var points = [40, 100, 1, 5, 25, 10];
  document.getElementById("demo").innerHTML = points;

  function  myFunction(){
    points.sort(function (a,b){return a-b});
    document.getElementById("demo").innerHTML=points;
  }

</script>
  </body>
</html>

<!--
1,5,10,25,40,100

降序排序：points.sort(function(a, b){return b - a});
比值函数详见109
-->